/*
 * TransiCast / Qt
 * (c) 2012 Joachim Pfeiffer
 * Please refer to http://code.google.com/p/transitacst for more information
 */
#ifndef BOOKMARKS_HPP
#define BOOKMARKS_HPP

#include <QDialog>
#include <QMainWindow>
#include <QList>
#include <QListWidgetItem>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QPushButton>
#include <QFile>

#include "bookmark.hpp"
#include "transitreemodel.hpp"

class Bookmarks : public QDialog
{
    Q_OBJECT
public:
    explicit Bookmarks(QMainWindow *parent = NULL);
    void addBookmark(Bookmark *bookmark = NULL);
    void loadBookmarks();
    void open(bool clear);
    void associateModel(TransiTreeModel *model = NULL);

signals:

public slots:
    void accept();
    void close();

private:

    QMainWindow         *modelParent;

    QList<Bookmark *>   bookmarks;

    // Bookmarks XML file tags
    QString             bookmarksFilename;
    QString             topLevelElement;
    QString             bookmarkTag;
    QString             agencyNameAttr;
    QString             agencyIdAttr;
    QString             agencyTopAttr;
    QString             agencyLeftAttr;
    QString             agencyBottomAttr;
    QString             agencyRightAttr;
    QString             agencyRtAttr;
    QString             routeNameAttr;
    QString             stopNameAttr;
    QString             stopIdAttr;

    TransiTreeModel     *transiTreeModel;

    bool                clear;
    Bookmark            *selectedBookmark;

    QFile               *bookmarksFile;

    QListWidget         *bookmarksWidget;
    QVBoxLayout         *mainLayout;
    QHBoxLayout         *buttonLayout;
    QPushButton         *backButton;

private slots:
    void bookmarkClicked(QListWidgetItem *item = NULL);
    void saveBookmarks();
};

#endif // BOOKMARKS_HPP
